<?php
    /* 
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    /**
    * Description of user_m
    *
    * @author Gidaff_01
    */
    class User_m extends Model{
        //put your code here
        function User_m() {
            parent::Model();
            $this->load->database();
        }

        function get_gardient($email, $password) {
            $this->db->select('seating_gardient_account.id,seating_gardient_account.gardient_name,seating_gardient_account.password,seating_gardient_profile.avatar');
            $this->db->from('seating_gardient_account,seating_gardient_profile');
            $this->db->where('seating_gardient_account.id = seating_gardient_profile.gardient_id');
            $this->db->where(array('seating_gardient_account.gardient_name' => $email, 'seating_gardient_account.password' => $password));
            $query = $this->db->get();
            return $query;
        }

        function edit_profile($data,$id){
            return $this->db->update('seating_gardient_profile', $data, array('gardient_id' => $id));
        }

        function change_pass($data,$id){
            return $this->db->update('seating_gardient_account', $data, array('id' => $id));
        }

        function is_password($pass, $gardient_id) {
            $query = $this->db->get_where('seating_gardient_account', array('id' => $gardient_id, 'password' => $pass));
            if ($query->num_rows() > 0) {
                return true;
            }
            return false;
        }

        function get_deactivate_user($email){
            $this->db->select();
            $this->db->from('lehu_users');
            $this->db->where(array('email' => $email));
            $this->db->where(array('active' => 0));
            $query = $this->db->get();
            return $query;
        }

        function get_user($email, $password) {
            $this->db->select('lehu_users.id,lehu_users.email,lehu_users.password,lehu_users.group_id,lehu_profiles.display_name,lehu_profiles.gravatar');
            $this->db->from('lehu_users');
            $this->db->join('lehu_profiles', 'lehu_profiles.user_id = lehu_users.id');
            $this->db->where(array('lehu_users.email' => $email, 'lehu_users.password' => $password));
            $query = $this->db->get();
            return $query;
        }

        function change_login_time($data, $userid) {
            $this->db->update('lehu_users', $data, array('id' => $userid));
        }
        /**/
        function get_account_infor_by_email($email){
            $this->db->select('seating_gardient_account.id,seating_gardient_account.gardient_name,seating_gardient_account.email');
            $this->db->from('seating_gardient_account');
            $this->db->where('seating_gardient_account.email',$email);
            return $this->db->get();
        }
        function update_temp_pass($email,$data){
            return $this->db->update('seating_gardient_account',$data);
        }

        function check_email($email){
            return $this->db->select()
            ->from('seating_gardient_account')
            ->where('email',$email)
            ->get();
        }

    }
?>
